How to check memory
There are several ways to check memory of a linux server. There are meminfo, top, vmstat, and free.
cat /proc/meminfo
The first is cat /proc/meminfo. Meminfo will show you everything about memory status of the Linux server in raw data. Total memory, free memory, available memory, buffers, cache, active and inactive.
The below information is an example of what you will see when you use meminfo.
MemTotal: 594900 kBMemFree: 64500 kBMemAvailable: 316728 kBBuffers: 49568 kBCached: 262412 kBSwapCached: 0 kBActive: 258940 kBInactive: 144904 kBActive(anon): 92296 kBInactive(anon): 428 kBActive(file): 166644 kBInactive(file): 144476 kBUnevictable: 0 kBMlocked: 0 kBSwapTotal: 0 kBSwapFree: 0 kBDirty: 12 kBWriteback: 0 kBAnonPages: 91904 kBMapped: 36320 kBShmem: 860 kBSlab: 71748 kBSReclaimable: 41740 kBSUnreclaim: 30008 kBKernelStack: 1884 kBPageTables: 4496 kBNFS_Unstable: 0 kBBounce: 0 kBWritebackTmp: 0 kBCommitLimit: 297448 kBCommitted_AS: 462648 kBVmallocTotal: 34359738367 kBVmallocUsed: 0 kBVmallocChunk: 0 kBHardwareCorrupted: 0 kBAnonHugePages: 0 kBShmemHugePages: 0 kBShmemPmdMapped: 0 kBCmaTotal: 0 kBCmaFree: 0 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 2048 kBDirectMap4k: 111984 kBDirectMap2M: 516096 kBDirectMap1G: 0 kB
top
The second is top, which shows what memory is used by the user (including root) by command, and it's always active until you type in CTRL+C. The stats you see when you use top are live, meaning that it's always active.
Top provides a real time summary of the top users of your server's resources.
Load average: three numbers that roughly relefect demand for your CPUs on the system (1,5,15 minutes) if it's higher than the # of the Cpus you have, that's often bad.
Memory: 4 numbers: total/fre/used/cached. One perhaps unexpeted thing: Total is not free+used but free+used+ + filesystem cache
%CPU: this colum is given as % of a single core. If you have 4 cores, this can go up to 400%.
RES: or resident set size aka how much memory your process is using
SHR is how much of the RES is shared with other processes.
Htop is merely a prettier version of top where it actually shows you graphs.
vmstat
vmstat shows you a shows you asimple version of what memory is available on your server. Stats listed are memory, swap, ic system, and cpu
free
Free Just shows total used, free, shared buff/cahe and available memory of the system.